package com.zl.quickdoc.resolver.converter.impl;

import com.zl.quickdoc.resolver.converter.AbstractJavaDocTag;
import com.zl.quickdoc.resolver.converter.JavaParserTagConverter;
import com.zl.quickdoc.utils.CommentUtils;

/**
 * 基于JavaParser包的默认注释解析转换器
 *
 * @author zhouliang
 *
 */
public class DefaultStringParserTagConverterImpl implements JavaParserTagConverter {

    @SuppressWarnings("unchecked")
    @Override
    public AbstractJavaDocTag<String> converter(String comments) {
        String tagType = CommentUtils.getTagType(comments);
        String value = comments.substring(tagType.length()).trim();
        return new DocTagImpl(tagType, value);
    }
    
    /**
     * 简单文本型注释标签实现
     * @author zhouliang
     */
    public class DocTagImpl extends AbstractJavaDocTag<String> {
        private String value;

        public DocTagImpl(String tagName, String value) {
            super(tagName);
            this.value = value;
        }

        @Override
        public String getValues() {
            return value;
        }
    }
}
